---
title: Account Types
description: Anchor Account Type Examples
---

Minimal reference examples for Anchor
[account types](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/index.html).

See the account types
[source code](https://github.com/coral-xyz/anchor/tree/0e5285aecdf410fa0779b7cd09a47f235882c156/lang/src/accounts)
for implementation details.

## Account Types

### `Account<'info, T>`

Description: Account container that checks ownership on deserialization  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/Account)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/Account)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word: Account]
    // [!code highlight]
    pub account: Account<'info, CustomAccountType>,
}

#[account]
pub struct CustomAccountType {
    data: u64,
}
```

### `AccountInfo<'info>`

Description: AccountInfo can be used as a type but Unchecked Account should be
used instead  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/AccountInfo)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/AccountInfo)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    /// CHECK: AccountInfo is an unchecked account
    // [!code word:AccountInfo]
    // [!code highlight]
    pub unchecked_account: AccountInfo<'info>,
}
```

### `AccountLoader<'info, T>`

Description: Type facilitating on demand zero copy deserialization  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/AccountLoader)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/AccountLoader)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word:AccountLoader]
    // [!code highlight]
    pub account: AccountLoader<'info, ZeroCopyAccountType>,
}

#[account(zero_copy)]
pub struct ZeroCopyAccountType {
    data: u64,
}
```

### `Box<Account<'info, T>>`

Description: Box type to save stack space  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/Box)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/Box)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word:Box]
    // [!code highlight]
    pub account: Box<Account<'info, AccountType>>,
}
```

### `Interface<'info, T>`

Description: Type validating that the account is one of a set of given
Programs  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/Interface)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/Interface)

```rust title="snippet"
// Token program or Token2022 program
use anchor_spl::token_interface::TokenInterface;

#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word: Interface]
    // [!code highlight]
    pub program: Interface<'info, TokenInterface>,
}
```

### `InterfaceAccount<'info, T>`

Description: Account container that checks ownership on deserialization  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/InterfaceAccount)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/InterfaceAccount)

```rust title="snippet"
// Token program or Token2022 program Mint/TokenAccount
use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface};

#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word:InterfaceAccount]
    // [!code highlight:2]
    pub mint: InterfaceAccount<'info, Mint>,
    pub token: InterfaceAccount<'info, TokenAccount>,
    pub program: Interface<'info, TokenInterface>,
}
```

### `Option<Account<'info, T>>`

Description: Option type for optional accounts  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/Option)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/Option)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word:Option]
    // [!code highlight]
    pub account: Option<Account<'info, AccountType>>,
}
```

### `Program<'info, T>`

Description: Type validating that the account is the given Program  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/Program)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/Program)

```rust title="snippet"
use anchor_spl::token::Token;

#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word:Program]
    // [!code highlight:2]
    pub system_program: Program<'info, System>,
    pub token_program: Program<'info, Token>,
}
```

### `Signer<'info>`

Description: Type validating that the account signed the transaction  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/Signer)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/Signer)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word:Signer]
    // [!code highlight]
    pub signer: Signer<'info>,
}
```

### `SystemAccount<'info>`

Description: Type validating that the account is owned by the system program  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/SystemAccount)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/SystemAccount)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word:SystemAccount]
    // [!code highlight]
    pub account: SystemAccount<'info>,
}
```

### `Sysvar<'info, T>`

Description: Type validating that the account is a sysvar and deserializing it  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/Sysvar)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/Sysvar)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // [!code word:Sysvar]
    // [!code highlight:2]
    pub rent: Sysvar<'info, Rent>,
    pub clock: Sysvar<'info, Clock>,
}
```

### `UncheckedAccount<'info>`

Description: Explicit wrapper for AccountInfo types to emphasize that no checks
are performed  
Examples: [Github](https://github.com/solana-developers/anchor-examples/tree/main/account-types/UncheckedAccount)
|
[Solpg](https://beta.solpg.io/https://github.com/solana-developers/anchor-examples/tree/main/account-types/UncheckedAccount)

```rust title="snippet"
#[derive(Accounts)]
pub struct InstructionAccounts<'info> {
    // CHECK: No checks are performed
    // [!code word:UncheckedAccount]
    // [!code highlight]
    pub account: UncheckedAccount<'info>,
}
```
